package com.agsmobi.digitapp;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class MainActivity extends BaseActivity implements OnItemSelectedListener {

	Spinner spinChoose;
	String [] screenName = new String [] {
			"NumberTiles", "HorizontalScrollNumberTiles", "EnergyBar", 
			"ScoreCounter", "Drag & Drop example for HorizontalScrollNumberTiles", "StarParticleEffect"
	};
	boolean isFirstRun = true;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		loadControl();
	}
	
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		isFirstRun = true;
	}
	
	@Override
	protected void loadControl() {
		// TODO Auto-generated method stub
		super.loadControl();
		spinChoose = (Spinner)findViewById(R.id.spinnerChoose);
		loadDataToSpinner(spinChoose, screenName);
		spinChoose.setOnItemSelectedListener(this);
	}
	
	public void loadDataToSpinner (Spinner spinView, String [] data) {
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, data);
		spinView.setAdapter(adapter);
	}

	@Override
	public void onItemSelected(AdapterView<?> arg0, View arg1, int position,
			long arg3) {
		// TODO Auto-generated method stub
//		if(!isFirstRun){
//			switch (position) {
//			case 0:
//				startActivity(new Intent(MainActivity.this, NumberTilesActivity.class));
//				break;
//
//			case 1:
//				startActivity(new Intent(MainActivity.this, HorizontalScrollNumberTilesActivity.class));
//				break;
//
//			case 2:
//				startActivity(new Intent(MainActivity.this, EnergyBarActivity.class));
//				break;
//
//			case 3:
//				startActivity(new Intent(MainActivity.this, ScoreCounterActivity.class));
//				break;
//
//			case 4:
//				startActivity(new Intent(MainActivity.this, DragDropActivity.class));
//				break;
//
//			case 5:
//				startActivity(new Intent(MainActivity.this, StarPartcleEffectActivity.class));
//				break;
//
//			default:
//				break;
//			}
//		}
//		isFirstRun = false;
	}

	@Override
	public void onNothingSelected(AdapterView<?> arg0) {
		// TODO Auto-generated method stub
		
	}

	
}
